----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_A5_between_within.log
  log type:  text
 opened on:   4 Nov 2022, 09:45:42

. *-------------------------------------------------------------------------------
. 
. 
. *Merge the baseline regression (with country specific weights)  with a regressions with 
. *-----------------------------------------------------------------
. clear all

. use "${data}/estimates_agg_naics_sales_s1_base_woparent.dta", clear

. tempfile reg_weights

. save `reg_weights', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_27c8_000007.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_27c8_000007.tmp saved

. 
. local extra "weightsFR"

. clear all

. use "${data}/estimates_agg_naics_sales_s1_base_woparent_`extra'.dta", clear

. rename D_A D_A_fr

. tempfile fr_weights

. save `fr_weights', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_27c8_000008.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_27c8_000008.tmp saved

. 
. use `reg_weights', clear

. merge 1:1 year isocode using `fr_weights', keepusing(D_A_fr)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                27  (_merge==3)
    -----------------------------------------

. drop _merge

. 
. 
. local grvar0 "gdp_pw_ppp" 

. local grvar1 "" 

. local rr ""

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str5, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                                27  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,985 observations deleted)

. drop _merge

. 
. foreach var in D_A D_A_fr {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }

. 
. local LHS1 D_`var3'_phi

. local LHS2 D_`var3'_fr_phi

. local RHS ln_`grvar0'

.         
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2043066    .1622385  -.4886707   .0749743
ln_gdp_pw_~p |         27   -.3431099    .2740156  -.9310113          0
  D_A_fr_phi |         27    -.236281    .1582185  -.5183639   .0323879

. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. local firm_emb "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}" 

. local ctry_emb "{&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local title "Affiliates older than `edad' years"

. local title ""

. 
. reg `LHS1' `RHS'

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     12.07
       Model |  .222837263         1  .222837263   Prob > F        =    0.0019
    Residual |  .461517255        25   .01846069   R-squared       =    0.3256
-------------+----------------------------------   Adj R-squared   =    0.2986
       Total |  .684354518        26  .026321328   Root MSE        =    .13587

-------------------------------------------------------------------------------
      D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
ln_gdp_pw_ppp |   .3378563   .0972438     3.47   0.002     .1375789    .5381337
        _cons |  -.0883848   .0423907    -2.09   0.047    -.1756901   -.0010794
-------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     16.07
       Model |  .254689061         1  .254689061   Prob > F        =    0.0005
    Residual |  .396171044        25  .015846842   R-squared       =    0.3913
-------------+----------------------------------   Adj R-squared   =    0.3670
       Total |  .650860105        26  .025033081   Root MSE        =    .12588

-------------------------------------------------------------------------------
   D_A_fr_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
ln_gdp_pw_ppp |   .3611962   .0900968     4.01   0.000     .1756384    .5467541
        _cons |   -.112351   .0392752    -2.86   0.008    -.1932398   -.0314622
-------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c2: display %-03.2fc round(b[1,1],0.01)

. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. display $c1
.34

. display $se1
.1

. display $c2
.36

. display $se2
.09

. 
. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(small) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(small) mlabsize(small)

. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  ylabel(-1(0.5)0.5, format(%5.1f) labsize(medlarge)
> ) xlabel(-1(0.2)0, format(%5.1f) labsize(medlarge)) ///
>         title("`title'", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
. graph export "${rappendix}/fig_A5_between_within.pdf", replace
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A5_between_within.pdf written in 
> PDF format)

. 
. log close 
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_A5_between_within.log
  log type:  text
 closed on:   4 Nov 2022, 09:45:45
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
